from 第18天.interface.wechat_request import WechatRequest


class WechatUserRequest(WechatRequest):
    def get_user_id_by_phone(self, phone_num: str):
        """
        根据手机号查询员工 ID
        :param phone_num:
        :return:
        """
        result_json = self.post("/cgi-bin/user/getuserid", {
           "mobile": phone_num
        })
        self._assert_result(result_json)
        return result_json.get("userid")

    def get_user_id_by_department(self):
        """
        查询部门中员工所有的信息
        :return:
        """
        result_json = self.post("/cgi-bin/user/list_id", {
            "limit": 10000
        })
        self._assert_result(result_json)
        return result_json.get("dept_user")


if __name__ == "__main__":
    wechat_user_request = WechatUserRequest()
    result_json = wechat_user_request.get_user_id_by_department()
    print(result_json)
